<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/kendocommon.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>商机提示（来源入会）</title>
    <meta charset="utf-8">
    <style>
    	table{font-size:12px}
    </style>
    <script>
        $(document).ready(function() {
        	$("#toolbar").kendoToolBar({
	            resizable: false,
	            items: [
	            	{ type: "separator" },
	                //{ template: toolbarTemp},
					//{ type: "separator" },
	                //{ template: selectTemp},
	                //{ type: "separator" },
	                { type: "button", text: "刷新",click: queryCustomerList }
	            ]
	        });
	        
            dataSource = new kendo.data.DataSource({
                transport: {
                    read:  {
                        url: "${path}/assist/queryBizCueByApplication",
                        dataType: "json"
                    }
                },
                //group: [{field: "deptName"}],
                serverPaging: true,
                serverFiltering: true,
                pageSize: 15,
                schema: {
                	data:"data",
               		total:"total"
                }
            });
            
            $("#grid").kendoGrid({
                dataSource: dataSource,
                //pageable: true,
                pageable: {
					refresh: true,
					pageSizes: true,
					buttonCount: 5,
					page: 1,
					pageSize: 10,
					pageSizes: [10, 20, 30],
					messages: {
						display: "显示 {0}-{1} 共 {2} 项",
						empty: "没有数据",
						itemsPerPage: "每面显示数量",
						first: "第一页",
						last: "最后一页",
						next: "下一页",
						previous: "上一页"
					}
				},
                selectable: "multiple row",
                allowCopy: true,
                groupable: {
                    messages: {
                      empty: "将列拖拽到此处进行分类查看"
                    }
                },
                editable: "popup",
                columns: [
                	//{ field:"c_user_id", template: "<input type='checkbox' id='#:c_user_id#' class='gridchk'/>",width: "120px",
                	//	headerTemplate: '<input type="checkbox" id="check-all"/>'},
                    { field:"user_name", title: "姓名",width: "150px"},
                    { field:"interest_service", title: "感兴趣的服务",width: "250px"},
                    { field:"phone", title: "联系方式",width: "250px"},
                    { field:"c_user_name", title: "推荐人",width: "150px"}
                    //{ field: "UnitsInStock", title:"Units In Stock", width:"120px"},//,format:"{0:yyyy/MM/dd}"
                    //{ command: [{name:"editrow",text:"<span class='k-icon k-edit'></span>查看",click:queryCustomerInfo,buttonType:"ImageAndText"}], title: "操作", width: "100px" }
                    ]
            });
            
            $('#check-all').change(function(){
            	var grid = $("#grid").data("kendoGrid");
            	$.each(grid.items(), function (i, item) {
					var cbxController = $(item).find(".gridchk");
					var isChecked = cbxController.is(":checked");
					if(isChecked){
						cbxController.prop("checked",false); 
					}else{
						cbxController.prop("checked",true); 
					}
				});
            });
            
            $('#grid').css("height",document.body.clientHeight-40);
            //$("#isMember").kendoComboBox();
            
		});
		
		
		var queryCustomerList = function(e){//查询
			var grid = $("#grid").data("kendoGrid");
			var checkedIDs = new Array();
			$.each(grid.items(), function (i, item) {
				var cbxController = $(item).find(".gridchk");
				var isChecked = cbxController.is(":checked");
				var curData = grid.dataItem(item);
				if (isChecked){
					checkedIDs.push(curData.phone);
					//console.log(curData.phone);
					//console.log(curData);
				}
			});
			
            var selectedRowIds = $("#grid").attr('data-sympleTech-KendoGrid-selected');
	        //console.log(selectedRowIds);
            
			//$("#grid").data("kendoGrid").dataSource.read({isMember:$("#isMember").data("kendoComboBox").value()});
			$("#grid").data("kendoGrid").dataSource.fetch();
			$("#grid").data("kendoGrid").dataSource.page(1);
		}
		
		var toolbarTemp = function(dataItem){
			return "<label>时间:</label><input name='querydate' id='querydate' class='k-textbox'>";
		}
		
		var selectTemp = function(dataItem){
			return "<label>是否会员:</label><select id='isMember' name='isMember'>"+
                		"<option value ='' selected='selected'></option>"+
                		"<option value ='1'>是</option>"+
                		"<option value ='0'>否</option>"+
		            "</select>";
		}
		
		var queryCustomerInfo = function(e){
			var grid = $("#grid").data("kendoGrid");
			e.preventDefault();
            var data = grid.dataItem($(e.currentTarget).closest("tr"));
            setFormData(data);
			$.fancybox($("#inlineForm"));
		    //var dInfo = dialog({
			//	title: '消息',
			//	content: document.getElementById("inlineForm")
		    //})
			//dInfo.showModal();
		}
		
		var setFormData = function(data){
			$('#baby_name').val(data.baby_name);
		}
		
    </script>
</head>
<body>
	<div id="toolbar" style="margin:2px"></div>
    <div id="grid" style="margin:2px;font-size:10px"></div>
    
    
    <div style="display: none;">		
		<div id="inlineForm" style="width:600px;overflow:auto;">
			<table>
                <tr>
                    <td style="width:100px;padding:5px">
                        <span  style="width:90px">客户名字</span>
                    </td>
                    <td style="width:220px;padding:5px">
                    	<input type="text" placeholder="标题" name="baby_name" id="baby_name"
                    		 style="width:200px" class="k-textbox" >
                    </td>
                    <td colspan="3" style="padding:5px" style="width:320px">
                    </td>
                </tr>
                
                <tr>
                    <td style="padding:5px">
                        <span  style="width:90px">开始日期</span>
                    </td>
                    <td style="padding:5px">
                        <input name="starttime" id="starttime" style="width:200px" class="k-textbox">
                    </td>
                    
                    <td style="padding:5px">
                        <span  style="width:90px">完成时间</span>
                    </td>
                    <td style="padding:5px">
                        <input style="width:200px" name="endtime" id="endtime" class="k-textbox">
                    </td>
                </tr>
                <tr>
                    <td style="width:100px;padding:5px">
                        <span  style="width:90px">内容</span>
                    </td>
                    <td colspan="3" style="padding:5px">
                        <textarea name="content" id="content" style="width:480px;height:200px" class="k-textbox"></textarea>
                    </td>
                </tr>
            </table>
		</div>
	</div>
    
</body>
</html>
